package rabbitmq.Direct;

import com.rabbitmq.client.Channel;
import rabbitmq.utils.MqUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Producer {

    private final static String queueName = "direct_logs";

    public static void main(String[] args) throws Exception {
        MqUtil mqUtil = new MqUtil();

        try (Channel channel = mqUtil.getChananel()) {
//             channel.exchangeDeclare(queueName,"fanout");
            HashMap<String, String> map = new HashMap<>();
            map.put("info", "提示信息");
            map.put("warning", "警告信息");
            map.put("error", "错误信息");
            System.out.println("请输入");
            for (Map.Entry<String, String> entry : map.entrySet()) {
                String routerKey = entry.getKey();
                String msg = entry.getValue();
                channel.basicPublish(queueName, routerKey, null, msg.getBytes("UTF-8"));
                System.out.println("发送成功");
            }
        }
    }
}

